home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-03 / qbasicpg.zip / DYNAMIC.BAS < prev    next >
BASIC Source File  |  1989-08-31  |  1KB  |  40 lines

  1. ' DYNAMIC.BAS
  2. ' This program reads information into three dynamic arrays and prints it.
  3.  
  4. OPTION BASE 1                  ' set base of all arrays to 1
  5.  
  6. CLS
  7.  
  8. INPUT "How many salesperson names would you like to enter?  ", persons%
  9.  
  10. IF (persons% > 0) THEN         ' must be at least one salesperson
  11.    
  12.     DIM salesGroup$(persons%)  ' dimension salesGroup$ string array
  13.     DIM bikesSold%(persons%)   ' dimension bikesSold% integer array
  14.     DIM totalSales!(persons%)  ' dimension totalSales! floating-pt. array
  15.  
  16.     PRINT
  17.  
  18.     FOR i% = 1 TO persons%     ' get salesperson name and sales data
  19.         INPUT "Enter salesperson name:  ", salesGroup$(i%)
  20.         INPUT "   Bikes sold:  ", bikesSold%(i%)
  21.         INPUT "   Total sales:  $", totalSales!(i%)
  22.         PRINT
  23.     NEXT i%
  24.  
  25.     PRINT "You entered the following sales data:"
  26.     PRINT
  27.     PRINT "Salesperson     Bikes sold     Total sales"
  28.     PRINT "------------------------------------------"
  29.     PRINT
  30.  
  31.     ' initialize tmp$, a formatting template for PRINT USING
  32.     tmp$ = "\               \ ###          $$####.##"
  33.  
  34.     FOR i% = 1 TO persons%     ' print contents of each array
  35.     PRINT USING tmp$; salesGroup$(i%); bikesSold%(i%); totalSales!(i%)
  36.     NEXT i%
  37.  
  38. END IF
  39.  
  40.